#define METERS_TO_FEET(meetsies) ((meetsies) * 3.2808399)
#define NMILES_TO_METERS(a) ((a) * 1852.0) /* nautical miles */
+#define METERS_TO_NMILES(a) ((a) / 1852.0)
+
#define MILES_TO_METERS(a) ((a) * 1609.344)
#define METERS_TO_MILES(a) ((a) / 1609.344)
#define FATHOMS_TO_METERS(a) ((a) * 1.8288)
typedef enum {
units_unknown = 0,
units_statute = 1,
- units_metric =2
+ units_metric = 2,
+ units_nautical =3
} fmt_units;
int fmt_setunits(fmt_units);
"Indicate direction of travel in track icons (default = 0)",
"0", ARGTYPE_BOOL, ARG_NOMINMAX },
{"units", &opt_units,
- "Units used when writing comments ('s'tatute or 'm'etric)",
+ "Units used when writing comments ('s'tatute, 'm'etric,' 'n'autical)",
"s", ARGTYPE_STRING, ARG_NOMINMAX },
{"labels", &opt_labels,
"Display labels on track and routepoints (default = 1)",
switch(u) {
case 's': fmt_setunits(units_statute); break;
case 'm': fmt_setunits(units_metric); break;
+ case 'n': fmt_setunits(units_nautical); break;
default: fatal("Units argument '%s' should be 's' for statute units or 'm' for metric.", opt_units); break;
}
/*
switch (u) {
case units_statute:
case units_metric:
+ case units_nautical:
units = u;
return 0;
default:
*tag = "mi";
}
break;
+ case units_nautical:
+ d = METERS_TO_NMILES(distance_meters);
+ *tag = "NM";
+ break;
case units_metric:
d = distance_meters;
if (d < 1000) {
d = METERS_TO_MILES(distance_meters_sec) * SECONDS_PER_HOUR ;
*tag = "mph";
break;
+ case units_nautical:
+ d = METERS_TO_NMILES(distance_meters_sec) * SECONDS_PER_HOUR ;
+ *tag = "knts";
+ break;
case units_metric:
d = distance_meters_sec * SECONDS_PER_HOUR;
*tag = "meters/hour";